/**
* Copyright 2023 PYSTOR DBS, Nanjing Pengyun Network Technology Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ 

package py.coordinator.task;


import py.common.DelayRequest;
import py.coordinator.configuration.CoordinatorConfigSingleton;
import py.coordinator.logmanager.IoContextManager;
import py.drivercontainer.utils.DriverContainerUtils;


public class ResendRequest extends DelayRequest {


  public static final int RESEND_LOG_TIME_DELAY_MAX = 500;
  private final IoContextManager manager;
  private final boolean needUpdateMembership;



  public ResendRequest(IoContextManager logManager, boolean needUpdateMembership) {
    this(logManager, needUpdateMembership,
        DriverContainerUtils.getExponentialBackoffSleepTime(
            CoordinatorConfigSingleton.getInstance().getResendDelayTimeUnitMs(),
            logManager.getFailTimes(),
            RESEND_LOG_TIME_DELAY_MAX));
  }



  public ResendRequest(IoContextManager logManager, boolean needUpdateMembership, long delay) {
    super(delay);
    this.manager = logManager;
    this.needUpdateMembership = needUpdateMembership;
  }

  public IoContextManager getIoContextManager() {
    return manager;
  }

  public boolean needUpdateMembership() {
    return needUpdateMembership;
  }
}
